﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EvolutionBaseTypes;
using EvolutionBaseTypes.Interfaces;

namespace Evolution.Structure.Globe.Details
{
    public class Building : ILoadable<Building>, IBuildable
    {

        public string Name { get;  set; }
        public int BuildingCosts { get; set; }
        public List<Technology> RequiredTechnologies { get; set; }
        public List<Benefit> Benefits { get; set; }

        public Building()
        {
            RequiredTechnologies = new List<Technology>();
        }

        /// <summary>
        /// Loads the data
        /// </summary>
        /// <param name="factory"></param>
        /// <returns>object with loaded data</returns>
        public Building LoadData(LoaderFactory<Building> factory)
        {
            try
            {
                Building temp = factory.Load();
                this.Name = temp.Name;
                this.BuildingCosts = temp.BuildingCosts;
                this.RequiredTechnologies = temp.RequiredTechnologies;
                this.Benefits = temp.Benefits;
                return this;
            }
            catch (Exception) { return null; }
        }

        public override string ToString()
        {
            return Name;
        }
    }
}
